package com.example.user3.demo.mvp.presenter;

import android.util.Log;

import com.example.user3.demo.bean.ChapterListBean;
import com.example.user3.demo.contract.MainContract;
import com.example.user3.demo.mvp.model.MainModel;
import com.google.gson.Gson;
import com.zzy.base.mvp.BasePresenter;
import com.zzy.base.mvp.IBaseView;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MainPresenter extends BasePresenter<MainContract.IView,MainModel> implements MainContract.IPresenter {

    @Override
    public void handleData() {
        getView().showLoading();
        getmModel().getChapterList(new Callback<ChapterListBean>() {
            @Override
            public void onResponse(Call<ChapterListBean> call, Response<ChapterListBean> response) {
                Log.i("zzy", new Gson().toJson(response.body()));
                getView().hideLoading();
                getView().success(new Gson().toJson(response.body()));


            }

            @Override
            public void onFailure(Call<ChapterListBean> call, Throwable t) {
                getView().hideLoading();

            }
        });

    }


    @Override
    public void attach(IBaseView view) {
        super.attach(view);
    }

    @Override
    public void detech() {
        super.detech();
    }
}
